package com.lin.spring.cloud.action.controller;

import com.lin.spring.cloud.action.model.License;
import com.lin.spring.cloud.action.service.LicenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("v1/organizations/{organizationId}/licenses")
public class LicenseController {
    @Autowired
    private LicenseService licenseService;

    @RequestMapping(value = "/{licenseId}", method = RequestMethod.GET)
    public License getLicenses(@PathVariable String organizationId, @PathVariable String licenseId) {
        return new License().withId(licenseId).withOrganizationId(organizationId).withProductName("picture").withLicenseType("sad");
    }

    @RequestMapping(value = "{licenseId}", method = RequestMethod.PUT)
    public String updateLicense(@PathVariable String licenseId) {
        return "This is the put";
    }

    @RequestMapping(value = "{licenseId}", method = RequestMethod.POST)
    public String saveLicense(String licenseId) {
        return "This is the post";
    }

    @RequestMapping(value = "{licenseId}", method = RequestMethod.DELETE)
    @ResponseStatus(HttpStatus.NO_CONTENT)
    public String deleteLicense(String licenseId) {
        return "This is the delete";
    }
}
